package com.fouram.core.base;

import com.fouram.core.utils.ParamUtils;

/**
 * @author Liup
 */
public abstract class BasePageBo extends BaseBo {

	private static final int DEFAULT_PAGE_NO = 1;
	private static final int DEFAULT_PAGE_SIZE = 20;
	private static final int MIN_PAGE_SIZE = 1;
	private static final int MAX_PAGE_SIZE = 1024;

	/**
	 * 请求页码-默认1，从1开始
	 */
	private int pageNo = DEFAULT_PAGE_NO;

	/**
	 * 每页条数-默认20，最大1024
	 */
	private int pageSize = DEFAULT_PAGE_SIZE;

	@Override
	public void checkInput() {
		super.checkInput();
		ParamUtils.expectTrue(this.pageNo >= DEFAULT_PAGE_NO, String.format("请求页码不能小于%d", 1));
		ParamUtils.expectInRange(this.pageSize, MIN_PAGE_SIZE, MAX_PAGE_SIZE, String.format("每页条数需在[%d, %d]范围内", 1, 1024));
	}

	public int getPageNo() {
		return this.pageNo;
	}

	public int getPageSize() {
		return this.pageSize;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

}